<template>
	<view class="content poRel">
		<swiper v-if="list.pic" class="wid100 borRad10" style="height: 640rpx;" circular :autoplay='true'>
			<swiper-item v-for="(item,index) in list.pic.split(',')" :key="index">
				<image :src="url+item" class="wh100"></image>
			</swiper-item>
		</swiper>
		<view class="wid90 mar mar-top30">
			<view class="foSi30 fowe600">{{list.name}}</view>
			<view class="mar-top20 dis disAl disJuB">
				<view class="fowe600 foSi30" style="color: #FF0000;">{{list.price}}积分</view>
				<view class="foSi20" style="color: #686868;">剩余：{{list.inventory}}</view>
			</view>
		</view>
		<view class="wid90 mar mar-top30">
			<view class="foSi35 fowe600 mar-bott30">兑换详情</view>
			<rich-text :nodes="list.content"></rich-text>
		</view>
		<view style="height: 120rpx;" :style="'padding-bottom: '+(bottomHight - 20)+'px;'"></view>
		<view class="wid100 bacFFF poFix" style="bottom: 0;">
			<view class="dis disAl" style="height: 120rpx;">
				<view class="hei80 wid90 mar borRad10 dis disAl disJuC foSi30 coFFF" 
					style="background-color: #035DFF;" @click.stop="tiaozhuan('/pages/commodity/exchange?id='+list.id)">消耗{{list.price}}积分兑换</view>
			</view>
			<view v-if="bottomHight != 0" :style="'height: '+(bottomHight - 20)+'px;'"></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				bottomHight: 0,
				id: 0,
				list: []
			}
		},
		onLoad(option) {
			let app = uni.getSystemInfoSync();
			this.bottomHight = app.safeAreaInsets.bottom //屏幕底部安全距离
			this.id = option.id
			this.getList()
		},
		methods: {
			getList() {
				var that = this;
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_goods_info',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						id: that.id
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							that.list = result.data
							that.list.content = that.list.content.replace(/<img/gi, "<img class='richImg'");
						}
					}
				})
			},
			tiaozhuan(url){
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		background-color: #F8F9FD;
		height: 100vh;
	}
	.richImg {
	    width: 100% !important;
	    height: auto !important;
	}
</style>
